<div th:fragment="left">

	<script type="text/javascript" th:inline="javascript">
	var ups = [{id:1, parentId:0,name:"首页",url:"/v2/index/index",role:["ORG"]},
	           {id:2, parentId:0,name:"比赛管理",url:"",role:["ORG","TEACHER"]},
			   {id:3, parentId:0,name:"账户管理",url:"",role:["ORG"]},
			   {id:8, parentId:0,name:"新闻公告",url:"",role:["ORG"]},
			   {id:9, parentId:0,name:"用户管理",url:"",role:["Admin", "Temp"]},
			   
			   
			   {parentId:9,name:"机构管理",url:"/v2/org/list",role:["Temp", "Admin"]},
			   {parentId:9,name:"老师管理",url:"/v2/teacher/list",role:["Admin"]},
			   
			   
	           {parentId:2,name:"比赛列表",url:"/v2/evaluate/list",role:["ORG"]},
			   {parentId:2,name:"推荐比赛",url:"/v2/evaluate/ref",role:["ORG", "TEACHER"]},
			   {parentId:2,name:"我的评委",url:"/v2/jury/list",role:["ORG", "TEACHER"]},
			   
			   //{parentId:3,name:"收款设置",url:"/org/acc/conf",role:["ORG"]},
			   {parentId:3,name:"修改密码",url:"/org/acc/pwd",role:["ORG"]},
			   {parentId:3,name:"机构详情", menu:1,url:"/org/acc/orgdetails",role:["ORG"]},
			   
			   {parentId:8,name:"文章",url:"/v2/shop/article",role:["ORG"]},
			   {parentId:8,name:"公告",url:"/v2/shop/notice",role:["ORG"]},
			   {parentId:8,name:"照片墙",url:"/v2/shop/zpq",role:["ORG"]},
			   {parentId:8,name:"外链",url:"/v2/shop/new",role:["ORG"]},
			   
			   
			   //{id:13, parentId:3,name:"子账号",url:"/v2/acc/son"},
	           ];

	var openUrl = function(that, url){
		if(url != null && url!=''){
			location.href=url;
		} else {
			$(that).next().slideToggle(300);
		}
	}
	var serverUrl = [[${application.serverUrl}]]
	var qiniuUrl = [[${application.qiniuUrl}]]
	var serverH5Url= [[${application.serverH5Url}]]
	
	$(function(){
		$.setData({serverH5Url:serverH5Url});
		//$("#menu").loadData({list:ups,url2:location.pathname});
		var adminUserId = [[${session.user.adminUserId}]];
		var userType = [[${session.user.type.toString()}]];
		var roleTypes = [[${session.user.roleTypes}]];
		var newUps = [];
		$.each(ups, function(i,v){
			if(v.role.indexOf(userType) > -1){
				newUps[newUps.length] = v;
			} else {
				for(var i2=0;i2<roleTypes.length;i2++){
					var roleType = roleTypes[i2];
					if(v.role.indexOf(roleType) > -1){
						newUps[newUps.length] = v;
						return;
					}
				}
			}
			
		});
		$.setData({list:newUps,url2:location.pathname,adminUserId:adminUserId,userType:userType});
		
		$(".menu-list li.active").parent().prev().addClass("active");
		
		if(getCookie("menuState")=='open'){
			$(".content").addClass("close");	
			$(".left").css({width: '40px' });
			//$(".sold .os").html("收起");
		} else {
			$(".content").removeClass("close");
			$(".left").css({width: '200px'});
			//$(".sold .os").html("展开");
		}
		
		$(".sold .os").click(function(){
			if($(".content").hasClass("close")){
				$(".content").removeClass("close");
				$(".left").animate({width: '200px'});
				//$(this).html("收起");
				setCookie("menuState", "close");
			} else {
				$(".content").addClass("close");	
				$(".left").animate({width: '40px' });
				//$(this).html("展开");
				setCookie("menuState", "open");
			}
		});
	});
	
	</script>
    <div class="menu">
        <div class="sold">
            <ul class="sold-list">
                <li class="os"><i></i></li>
            </ul>
        </div>
        <div class="menu-context">
        	
        	<div class="menu-item" data-wyx-for="{data : list}" data-wyx-if="{data.parentId==0}">
               <div data-wyx-class="{data.url===url2?'active':''} menu-title menu-{data.id}" data-wyx-onclick="openUrl(this, '{data.url}')">
					<span class="menu-text" data-wyx-text="{data.name}"></span>
					<i class="menu-down" data-wyx-if="{data.url == ''}"></i>
				</div>
                <ul class="menu-list">
                   	<li data-wyx-for="{data2 : list}"  data-wyx-text="{data2.name}" data-wyx-if="{data.id == data2.parentId}" data-wyx-class="{data2.url===url2?'active':''}" data-wyx-onclick="openUrl(this, '{data2.url}')">
					</li>
                </ul>
            </div>
            
            
            
        
        	<script type="text/template" id="menu">
			#for(data:list)#
			#if(data.parentId==0)#
			<div class="menu-item">
                <div class="menu-title #if(data.url==url2)# active #endif# menu-#{data.id}# " onclick="openUrl(this, '#{data.url}#')">
					<span class="menu-text">#{data.name}#</span>
					#if(data.url=='')#
					<i class="menu-down"></i>
					#endif#
				</div>
                <ul class="menu-list">
					#for(data2:list)#
						#if(data.id==data2.parentId)#
                    	<li class=" #if(data2.url==url2)# active #endif# " onclick="openUrl(this, '#{data2.url}#')">
							#{data2.name}#
						</li>
						#endif#
					#endfor#
                </ul>
            </div>
			#endif#
			#endfor#
        	</script>
        </div>
    </div>
</div>